package com.llws.petgoodsshop.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class FileUploadConfig implements WebMvcConfigurer {
    //@Value可以将配置文件的内容自动注入到属性内
    @Value("${uploadPathImg}")
    private String uploadPathImg;   //图标物理存储路径

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry){
        registry.addResourceHandler("/uploadImg/**")
                .addResourceLocations("file:"+uploadPathImg);
    }
}
